<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        user-card{
            display: flex;
            align-items: center;
            width: 450px;
            height: 180px;
            background-color: #d4d4d4;
            border: 1px solid #d5d5d5;
            box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
            border-radius: 3px;
            overflow: hidden;
            padding: 10px;
            box-sizing: border-box;
            font-family: 'Poppins', sans-serif;
        }
        .image {
            flex: 0 0 auto;
            width: 160px;
            height: 160px;
            vertical-align: middle;
            border-radius: 5px;
        }

        .container {
            box-sizing: border-box;
            padding: 20px;
            height: 160px;
        }

        .container>.name {
            font-size: 20px;
            font-weight: 600;
            line-height: 1;
            margin: 0;
            margin-bottom: 5px;
        }

        .container>.email {
            font-size: 12px;
            opacity: 0.75;
            line-height: 1;
            margin: 0;
            margin-bottom: 15px;
        }

        .container>.button {
            padding: 10px 25px;
            font-size: 12px;
            border-radius: 5px;
            text-transform: uppercase;
        }
    </style>
</head>

<body>
    <h2>h2标签</h2>
    <itany>自定义标签</itany>
    <hr>
    <user-card></user-card>
    <hr>
    <user-card></user-card>
    <hr>
    <user-card></user-card>



    <script>
        // 创建了一个用于构成新标签的 构造函数
        class UserCard extends HTMLElement {
            // 构造器方法会在该 class类被创建时调用
            constructor() {
                super(); // 在创建该对象前先创建 HTMLElement 对象
                // 自定义当前创建标签的页面结构和样式功能
                var image = document.createElement('img');
                image.src = 'https://semantic-ui.com/images/avatar2/large/kristy.png';
                image.classList.add('image');

                var container = document.createElement('div');
                container.classList.add('container');

                var name = document.createElement('p');
                name.classList.add('name');
                name.innerText = 'User Name';

                var email = document.createElement('p');
                email.classList.add('email');
                email.innerText = 'yourmail@some-email.com';

                var button = document.createElement('button');
                button.classList.add('button');
                button.innerText = 'Follow';

                container.append(name, email, button);
                this.append(image, container);
            }
        }
        // window.customElements.define(标签名,标签构造函数);
        window.customElements.define("user-card", UserCard);
    </script>
</body>

</html>